﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Milan.Diagnostics;

namespace Milan.Deploy
{
	/// <summary>
	/// Invoke this class in the main routine to define a local user only application.
	/// A local user only application will check for new versions within this instance.
	/// This will instantiate a download scanner, upgrade scanner and log scanner thread.
	/// </summary>
	public class LocalUserOnly : Application, IDisposable
	{
		public LocalUserOnly(string[] args, string statuServer=null) : base(args)
		{
			log.Start();
			// Run the status server, which helps control this application and check its health and terminate it if needed.
			this.RunService(new Milan.Diagnostics.StatusServer(this, statuServer), Application.Type.BackgroundWorker, Application.TriggerType.RunAlways);
			// Add the reporter service
			this.RunService(new Reporter(this), Type.BackgroundWorker, TriggerType.RunAlways);
			// Add the download service -- which downloads an update of the application in the background
			this.RunService(new DownloadScanner(this), Type.BackgroundWorker, TriggerType.RunAlways);
			// Add the upgrade scanner service -- 
			this.RunService(new UpgradeScanner(this), Type.BackgroundWorker, TriggerType.RunAlways);
		}
		public new void Dispose()
		{
			log.Stop();
			base.Dispose(); 
		}
	}
}
